package com.pi.stroop.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pi.stroop.controller.facade.StroopPayFacade;
import com.pi.stroop.dao.entity.MemberPayRecordEntity;
import com.pi.stroop.service.MemberPayRecordService;

@RequestMapping("/pay/record")
@Controller
public class StroopPayController {
  
  @Autowired
  private MemberPayRecordService memberPayRecordService;
  @Autowired
  private StroopPayFacade stroopPayFacade; 
  @RequestMapping("/list")
  public String list() {
    return "stroop/pay/record/list";
  }
  
  @RequestMapping("/list/query")
  @ResponseBody
  public Map<String, Object> queryMemberPayRecord(Long userId, Integer page, Integer rows){
    Map<String, Object> map = new HashMap<>();
    List<MemberPayRecordEntity> list = memberPayRecordService.queryMemberPayRecord(userId, rows, page);
    long count = memberPayRecordService.countMemberPayRecord(userId);
    map.put("total", count);
    map.put("rows", stroopPayFacade.translateMemberPayRecordRecord(list));
    return map;
  }
}
